/**
 * Created By zhangQ 2018/3/7
 */
import axiosUtils from '@api/env/axiosEnv'

let customAxios = axiosUtils._initAxios()

// 废弃
export function getTruckList (param) {
  return customAxios({
    url: '/main/fleet/getTruckList',
    method: 'post',
    data: {
      page: param.page,
      pageSize: param.pageSize
    }
  })
}

export function getTruckInfo (param) {
  return customAxios({
    url: '/main/fleet/getTruckInfo',
    method: 'post',
    data: {
      truckId: param.truckId
    }
  })
}

export function getTruckTypeList (param) {
  return customAxios({
    url: '/main/fleet/getTruckTypeList',
    method: 'get'
  })
}

export function editTruck (param) {
  console.log(param)
  return customAxios({
    url: '/main/fleet/editTruck',
    method: 'post',
    data: {
      id: param.id,
      truckNo: param.truckNo,
      type: param.type
    }
  })
}

export function deleteTruck (param) {
  console.log(param)
  return customAxios({
    url: '/main/fleet/deleteTruck',
    method: 'post',
    data: {
      id: param.id
    }
  })
}

export function addTruck (param) {
  return customAxios({
    url: '/main/fleet/addTruck',
    method: 'post',
    data: {
      truckNo: param.truckNo,
      type: param.type
    }
  })
}

export function getdriverlist (param) {
  return customAxios({
    url: '/main/fleet/getDriverList',
    method: 'post',
    data: {
      page: param.page,
      pageSize: param.pageSize
    }
  })
}

export function addDriver (param) {
  return customAxios({
    url: '/main/fleet/addDriver',
    method: 'post',
    data: {
      truckId: param.truckId,
      loginName: param.loginName,
      mobile: param.mobile,
      email: param.email,
      pwd: param.pwd,
      realName: param.realName
    }
  })
}

export function getDriverInfo (param) {
  return customAxios({
    url: '/main/fleet/getDriverInfo',
    method: 'post',
    data: {
      driverId: param.driverId
    }
  })
}

export function editDriver (param) {
  let data = {
    driverId: param.userId,
    loginName: param.loginName,
    mobile: param.mobile,
    email: param.mail,
    pwd: param.pwd,
    realName: param.realName
  }
  if (param.truckId) {
    data.truckId = param.truckId
  }
  return customAxios({
    url: '/main/fleet/editDriver',
    method: 'post',
    data: data
  })
}

export function deleteDriver (param) {
  return customAxios({
    url: '/main/fleet/deleteDriver',
    method: 'post',
    data: {
      loginName: param.loginName
    }
  })
}

export function getMainOrderListByTruckId (param) {
  return customAxios({
    url: '/main/fleet/getMainOrderListByTruckId',
    method: 'post',
    data: {
      status: param.status,
      page: param.page,
      pageSize: param.pageSize
    }
  })
}

export function getAbilityList (param) {
  return customAxios({
    url: '/main/fleet/getDriverAbilityList',
    method: 'post',
    data: {
      startTime: param.startTime,
      endTime: param.endTime,
      type: param.type,
      sortBy: param.sortBy
    }
  })
}

export function dispatchDriver (param) {
  console.log(param)
  return customAxios({
    url: '/main/fleet/dispatchDriver',
    method: 'post',
    data: {
      loginNames: param.loginNames,
      mainOrderNo: param.mainOrderNo
    }
  })
}

export function getSubOrderListByMainOrderNo (param) {
  return customAxios({
    url: '/main/fleet/getSubOrderListByMainOrderNo',
    method: 'post',
    data: {
      mainOrderNo: param.mainOrderNo
    }
  })
}

export function uploadPound (param) {
  return customAxios({
    url: '/main/fleet/uploadPound',
    method: 'post',
    data: {
      subOrderNo: param.subOrderNo,
      containerNo: param.containerNo,
      truckNo: param.truckNo,
      grossWeight: param.grossWeight,
      grossWeightTime: param.grossWeightTime,
      tareWeight: param.tareWeight,
      tareWeightTime: param.tareWeightTime,
      netWeight: param.netWeight,
      poundNo: param.poundNo
    }
  })
}

// 获取车辆列表
export function getTruckListByPage (param) {
  return customAxios({
    url: '/main/fleet/getTruckListByPage',
    method: 'post',
    data: param
  })
}

// 获取车辆位置
export function getG7TruckTrajectory (param) {
  return customAxios({
    url: '/main/fleet/getG7TruckTrajectory',
    method: 'post',
    data: param
  })
}

// 获取车辆列表小黄山
export function getTruckListByPageXHS (param) {
  return customAxios({
    url: '/main/fleet/getMainTruckListByPage',
    method: 'post',
    data: param
  })
}

// 获取司机列表
export function getDriverListByPageXHS (param) {
  return customAxios({
    url: '/main/fleet/getMainDriverListByPage',
    method: 'post',
    data: param
  })
}

// 获取司机列表
export function getDriverListByPage (param) {
  return customAxios({
    url: '/main/fleet/getDriverListByPage',
    method: 'post',
    data: param
  })
}

// 获取司机位置信息
export function getFleetToDriverLocation (param) {
  return customAxios({
    url: '/getFleetToDriverLocation',
    method: 'post',
    data: param
  })
}

// 获取车队列表
export function getOwnFleet () {
  return customAxios({
    url: '/main/station/getOwnFleetList',
    method: 'post'
  })
}

// 小黄山添加车辆
export function addTruckXHS (param) {
  return customAxios({
    url: '/main/fleet/addTruckXhs',
    method: 'post',
    data: {
      truckNo: param.truckNo,
      type: param.type,
      subFleetId: param.fleetId
    }
  })
}

// 小黄山编辑车辆
export function editTruckXHS (param) {
  console.log(param)
  return customAxios({
    url: '/main/fleet/editTruckXhs',
    method: 'post',
    data: {
      id: param.id,
      truckNo: param.truckNo,
      type: param.type,
      subFleetId: param.fleetId
    }
  })
}

// 小黄山删除车辆
export function deleteTruckXHS (param) {
  console.log(param)
  return customAxios({
    url: '/main/fleet/deleteTruckXhs',
    method: 'post',
    data: {
      id: param.id,
      fleetId: param.fleetId
    }
  })
}

// 小黄山获取司机信息
export function getDriverInfoXHS (param) {
  return customAxios({
    url: '/main/fleet/getDriverInfoXhs ',
    method: 'post',
    data: {
      driverId: param.driverId,
      subFleetId: param.fleetId
    }
  })
}

// 小黄山获取司机信息
export function deleteDriverXHS (param) {
  return customAxios({
    url: '/main/fleet/deleteDriverXhs',
    method: 'post',
    data: {
      driverId: param.driverId
    }
  })
}

export function addDriverXHS (param) {
  return customAxios({
    url: '/main/fleet/addDriverXhs',
    method: 'post',
    data: {
      subFleetId: param.fleetId,
      truckId: param.truckId,
      loginName: param.loginName,
      mobile: param.mobile,
      email: param.email,
      pwd: param.pwd,
      realName: param.realName
    }
  })
}

export function editDriverXHS (param) {
  let data = {
    driverId: param.userid,
    loginName: param.loginname,
    mobile: param.mobile,
    email: param.email,
    pwd: param.pwd,
    realName: param.realname,
    subFleetId: param.fleetid
  }
  if (param.truckid) {
    data.truckId = param.truckid
  }
  return customAxios({
    url: '/main/fleet/editDriverXhs',
    method: 'post',
    data: data
  })
}

// 小黄山获取司机，车队，列表
export function getTruckListXHS (param) {
  return customAxios({
    url: '/main/fleet/getTruckListXhs',
    method: 'post'
  })
}

// 获取小黄山总车队司机车辆列表
export function getFleetAndTruckList (param) {
  return customAxios({
    url: '/main/fleet/getFleetAndTruckList',
    method: 'post'
  })
}

// 小黄山车队派遣司机
export function assignmentForDriverXhs (param) {
  return customAxios({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    url: '/main/station/assignmentForDriverXhs',
    method: 'post',
    data: param
  })
}

export function getOwnDriverListByTrunkType (param) {
  return customAxios({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    url: '/main/fleet/getOwnDriverListByTrunkType',
    method: 'post',
    data: param
  })
}

export function fleetReceiverSave (param) {
  return customAxios({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    url: '/main/fleet/fleetReceiverSave',
    method: 'post',
    data: param
  })
}

export function fleetReceiverDel (id) {
  return customAxios({
    // headers: {
    //   'Content-Type': 'application/json;charset=UTF-8'
    // },
    url: '/main/fleet/fleetReceiverDel',
    method: 'post',
    data: id
  })
}

export function fleetReceiverList (param) {
  return customAxios({
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    url: '/main/fleet/fleetReceiverList',
    method: 'post',
    data: param
  })
}

export function getG7Data (param) {
  return customAxios({
    url: '/main/fleet/getG7Data',
    method: 'post',
    data: param
  })
}
